package com.kaifamiao.www.ioDemo.do0922;

import java.io.*;

public class FileReaderTest {

    public static void main(String[] args) {
        File file = new File("E:\\kaifamiao\\workspace\\idea--space\\io\\reader.txt");
        try {
            InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "gbk");
//            FileReader fr = new FileReader(file);

            //// 定义字符数组，作为装字符数据的容器
            char[] bytes = new char[2];

//            int ch = fr.read();//读取单个字节
            int len;
            while ((len = isr.read(bytes))!=-1){
                System.out.println(new String(bytes));
            }
            isr.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
